'use strict';
const pushRealTimeData = require('../../server/actions/meter/pushRealTimeData').pushRealTimeData;
const pushCalibrationData = require('../../server/actions/meter/pushCalibrationData').pushCalibrationData;
const pushWeatherData = require('../../server/actions/meter/pushWeatherData').pushWeatherData;
module.exports = async function (ctx) {
    let param = ctx.method === 'GET' ? ctx.query : ctx.request.fields;
    let action_type = param.fn;
    try {
        switch (action_type) {
            case '0':
                pushCalibrationData(param);
                ctx.body = { success: true };
                break;
            case '2':
                //dtu数据处理
                pushRealTimeData(param);
                ctx.body = { success: true };
                break;
            case '9':
                //天气数据处理
                pushWeatherData(param);
                ctx.body = { success: true };
                break;
            default:
                ctx.body = { success: false, message: '没有匹配到指定的模块' };

        }
    } catch (e) {
        console.log(e);
        ctx.body = { success: false, message: e.message };
    }
};